package MainTest;

import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;

import Database.DataBaseAccessor;
import beans.Information;
import factory.IncidentFactory;
import factory.InformationFactory;
import factory.NotificationFactory;
import factory.PositionFactory;

public class Mainttes {
	
	 public static Logger log = Logger.getLogger("log_file");
	 FileHandler hand;

	public Mainttes() {
		// TODO Auto-generated constructor stub
		
		try {
			hand = new FileHandler("MonLog.txt");
			log.addHandler(hand);
			SimpleFormatter formatter=new SimpleFormatter();
			hand.setFormatter(formatter);
			testDB();
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		Creator createur=new Creator();
		
		//la trame reçu
		byte t[]={2,2};
			
		createur.setTrame(t);
		createur.Create();
	}
	
	public static void main(String[] args) {
		new Mainttes();
	}
	
	public void testFactory(){
		InformationFactory PosFact = new PositionFactory();
		InformationFactory NotifFact = new NotificationFactory();
		InformationFactory IncidFact = new IncidentFactory();
		
		Information inf= null;
		
		inf=NotifFact.getInformation();
		//setter
		
		System.out.println(inf.toString());
		inf=IncidFact.getInformation();
		System.out.println(inf.toString());
		inf=PosFact.getInformation();
		System.out.println(inf.toString());

	}
	
	public void testDB(){

		DataBaseAccessor dbaccess=new DataBaseAccessor();
		dbaccess.createTablePrimK();
		dbaccess.insertionSelect();
		
	}

}
